package com.itbaima.csmall.stock.webapi.quartz;

import com.itbaima.csmall.stock.webapi.utils.RedisBloomUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

/**
 * <p>QuartzJob</p>
 *
 * @author Chen
 * @since 2023/3/11 15:01:01
 */
@Slf4j
public class QuartzJob implements Job {
    @Autowired
    private RedisBloomUtils redisBloomUtils;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("-------------------{}--------------------", LocalDateTime.now());
        // 先定义要保存到布隆过滤器的元素数组
        String[] colors = {"red", "origin", "yellow", "green", "blue", "pink", "white"};
        final String COLOR_BLOOM = "color_bloom";
        redisBloomUtils.bfmadd(COLOR_BLOOM, colors);
        String elm = "zhanghl";
        log.info("【{}】{}在定义的数组中", elm, redisBloomUtils.bfexists(COLOR_BLOOM, elm) ? "" : "不");
    }
}
